<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>论文答辩系统登录</title><!--
		<link href="extjs/resources/css/ext-all.css" rel="stylesheet"
			type="text/css" />
		<link href="extjs/resources/css/xtheme-gray.css" rel="stylesheet"
			type="text/css" />
		-->
		<link href="extjs/resources/css/ext-all.css" rel="stylesheet"
			type="text/css" />
		<link href="extjs/resources/css/xtheme-tp.css" rel="stylesheet"
			type="text/css" />
		<link href="login.css" rel="stylesheet"
			type="text/css" />
		
		<script type="text/javascript" src="extjs/ext-base.js"></script>
		<script type="text/javascript" src="extjs/ext-all.js"></script>
		<script type="text/javascript" src="extjs/ext-lang-zh_CN.js"></script>
		<script type="text/javascript">
		
		//点击提交时的处理方法
		var loginFunc=function(){
			loginPanel.form.doAction("submit", {
				url : "loginAction",
				method : "post",
				waitMsg: "正在登录，请稍后...",
				//params:{xx:xx},
				success : function(form, action) {
					Ext.Msg.alert("成功", "登录成功，页面正在跳转...");
					//表单提交成功后,调用的函数.参数分为两个,一个是提交的表单对象,另一个是JSP返回的参数值对象
                    var jsonobject = Ext.util.JSON.decode(action.response.responseText);   //将返回的JSON数据转换成JSON对象,转换失败即报错.
                    var type = jsonobject.type;
                    document.location = type;
					//document.location = 'index2.jsp';//方式1跳转
					//location.href = jmp.asp;//方式2登录成功后暂时用js做了跳转
				},
				failure : function(form, action) {
					Ext.Msg.alert("登录失败", "请检查登录信息是否填写正确");
				}
			});
		};
		
/*		var proxy = new Ext.data.MemoryProxy(
		[
			["graduate","学生"],
			["teacher","教师"],
			["dean","教务员"],
			["observer","管理员"]
		]
		);
		
		var typeReader = new Ext.data.ArrayReader({},[
			{name:"value",type:"string",mapping:0},
			{name:"display",type:"string",mapping:1}
		]);
		
		var store = new Ext.data.Store({
			proxy:proxy,
			reader:typeReader,
			autoLoad:true//自动加载数据，否则手动调用store.load();
		});*/
			
		var loginTypeStore = new Ext.data.SimpleStore({
			fields: ['value','display'],
			data: [
				["graduate","学生"],
				["teacher","教师"],
				["dean","教务员"],
				["observer","管理员"]
			]
		});
		var loginPanel= new Ext.form.FormPanel({
					//title:"登录",
					frame:false,
					border:false,
					autoHeight:true,
					width:300,
					labelWidth:60,
					labelAlign:"right",
					defaultType:"textfield",
					defaults:{width:230,anchor:"95%"},
					items:[{
						name:"username",//与action中的参数一致
						fieldLabel:"用户名"
					},{
						name:"password",
						fieldLabel:"密码",
						inputType:"password"
					},{
						xtype:"combo",
						hiddenName:"type",
						fieldLabel:"登录类型",
						triggerAction:"all",
						store:loginTypeStore,
						displayField:"display",
						valueField:"value",
						mode:"local",
						//readOnly:true,
						emptyText:"选择登录类型",
						anchor:"90%"
					}],		
					buttons:[{
						text:"登录",
						type:"submit",
						//html:"<img src='image/loginBtn.png'/>",
						//style:"background:#0000ff",
						//scale:"medium",
						handler:loginFunc
					}]
				});
				
		Ext.onReady(
			function(){
				Ext.QuickTips.init();
				loginPanel.render(Ext.get("loginPanel"));
			}
		);
		</script>

	</head>
	<body>
	<div id = "main" style = "background:url('image/colorbook.jpg') no-repeat 0 0 !important;height:800px;width:1200px;position:fixed" >
		<div id = "loginPanel" style ="margin-top: 240px;margin-left:300px">
		</div>	
	</div>
	</body>
</html>
